﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;//正则表达式的命名空间

namespace A61转义符
{
    class Program
    {
     
        //转义符
        static void Main1(string[] args)
        {
            Console.WriteLine("\"");
            Console.WriteLine("\\");
            Console.WriteLine("A\tB");
            Console.WriteLine("\a");
            Console.WriteLine("a\bc");
            Console.WriteLine("x\ny");

            //用@取消字符串中的转义符
            string path = @"C:\kingsoft\wps\dcsdk";
            Console.WriteLine(path);

        }
        //正则表达式
        static void Main(string[] args)
        {
            while (true)
            {
                //让用户输入邮箱
                Console.WriteLine("请输入邮箱:");
                string input = Console.ReadLine();
                //创建邮箱正则表达式对象
                Regex regex = new Regex("^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$");
                if (regex.IsMatch(input))
                {
                    Console.WriteLine("Ok");
                }
                else
                {
                    Console.WriteLine("邮箱格式不正确");
                }
            }
        }
    }
}
